using System;
using UnityEngine;

namespace PhysSound
{
	[Serializable]
	public struct Range
	{
		public float Min;

		public float Max;

		public Range(float min, float max)
		{
			Min = min;
			Max = max;
		}

		public bool isWithinRange(float f)
		{
			return f >= Min && f <= Max;
		}

		public float Clamp(float f)
		{
			return Mathf.Clamp(f, Min, Max);
		}

		public float RandomInRange()
		{
			return UnityEngine.Random.Range(Min, Max);
		}

		public int RandomInRangeInteger()
		{
			return (int)UnityEngine.Random.Range(Min, Max + 1f);
		}

		public float Lerp(float t)
		{
			return Min + (Max - Min) * t;
		}

		public float Normalize(float val)
		{
			if (val <= Min)
			{
				return 0f;
			}
			if (val >= Max)
			{
				return 1f;
			}
			return (val - Min) / (Max - Min);
		}
	}
}
